#!/usr/bin/env bash

set +u

DOCKER_IMAGE=authelia:dist

if [[ "${BUILDKITE_LABEL}" == ":hammer_and_wrench: Unit Test" ]]; then
  if [[ ! "${BUILDKITE_BRANCH}" =~ ^renovate/ ]]; then
    echo "--- :docker: Saving artifacts for :buildkite: :docker: :github: releases"
    mv goreleaser/* ./
    rm -rf goreleaser
  fi
fi

if [[ "${BUILDKITE_LABEL}" == ":docker: Build Image [coverage]" ]]; then
  docker save "${DOCKER_IMAGE}" | zstdmt -T0 -12 > "authelia-image-coverage.tar.zst"
fi
